const Sequelize = require('sequelize');
const sequelize = require('../config/sequelizeBase');


// CREATE TABLE IF NOT EXISTS `admin` (`id` BIGINT NOT NULL auto_increment , `account` VARCHAR(255) NOT NULL UNIQUE,  `name` VARCHAR(64) NOT NULL, `pwd` VARCHAR(255) NOT NULL,PRIMARY KEY (`id`)) ENGINE=InnoDB;
// CREATE TABLE IF NOT EXISTS `goodsDetail` (`id` BIGINT NOT NULL auto_increment , `goodsId` BIGINT NOT NULL, `specName` VARCHAR(500) NOT NULL, `stockNum` INTEGER NOT NULL DEFAULT 0, `unitPrice` FLOAT NOT NULL, `updatetime` DATETIME NOT NULL, `createtime` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;
//  CREATE TABLE IF NOT EXISTS `good` (`id` BIGINT NOT NULL auto_increment , `name` VARCHAR(500) NOT NULL, `typeId` BIGINT NOT NULL, `img` VARCHAR(500), `desc` TEXT, `updatetime` DATETIME NOT NULL, `createtime` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;
//  CREATE TABLE IF NOT EXISTS `type` (`id` BIGINT NOT NULL auto_increment , `name` VARCHAR(255) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;

//  CREATE TABLE IF NOT EXISTS `reply` (`id` BIGINT NOT NULL auto_increment , `messageId` BIGINT NOT NULL, `content` VARCHAR(500) NOT NULL, `createtime` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;
     
//  CREATE TABLE IF NOT EXISTS `comment` (`id` BIGINT NOT NULL auto_increment , `userId` BIGINT NOT NULL, `goodsId` BIGINT NOT NULL, `goodsDetailId` BIGINT NOT NULL, `orderId` BIGINT NOT NULL, `content` VARCHAR(500), `score` INTEGER NOT NULL, `createtime` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;

//  CREATE TABLE IF NOT EXISTS `message` (`id` BIGINT NOT NULL auto_increment , `userId` BIGINT NOT NULL, `goodsId` BIGINT NOT NULL, `content` VARCHAR(500) NOT NULL, `state` ENUM('0','1') NOT NULL DEFAULT '0', `createtime` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;
 
//  CREATE TABLE IF NOT EXISTS `user` (`id` BIGINT NOT NULL auto_increment , `email` VARCHAR(64) NOT NULL UNIQUE, `pwd` VARCHAR(255) NOT NULL, `nickname` VARCHAR(64) NOT NULL UNIQUE, `sex` ENUM('0', '1', '2') NOT NULL DEFAULT '0', `recipient` VARCHAR(64), `address` VARCHAR(500), `phone` VARCHAR(64), `headimg` VARCHAR(500) NOT NULL DEFAULT 'http://tvax4.sinaimg.cn/crop.0.0.480.480.180/768c39d5ly8fjje1d0teej20dc0dcq35.jpg', `updatetime` DATETIME NOT NULL, `createtime` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;
 
//   CREATE TABLE IF NOT EXISTS `order` (`id` BIGINT NOT NULL auto_increment , `userId` BIGINT NOT NULL, `goodsDetailId` BIGINT NOT NULL, `goodsNum` INTEGER NOT NULL, `amount` FLOAT NOT NULL, `state` ENUM('0','1','2','3') NOT NULL DEFAULT '0', `updatetime` DATETIME NOT NULL, `createtime` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB; 



const AdminModel = sequelize.define('admin',{
	id:{
		type:Sequelize.BIGINT,
		primaryKey:true,
		allowNull:false,
		autoIncrement:true
	},
	account:{
		type:Sequelize.STRING(255),
		unique:true,
		allowNull:false
	},
	name:{
		type:Sequelize.STRING(64),
		allowNull:false
	},
	pwd:{
		type:Sequelize.STRING(255),
		allowNull:false
	},
},{
	timestamps:false,
});

//全部同步
// AdminModel.sync(); 


module.exports = AdminModel;